package org.raymond.icloud.apis.admin.service;

import org.raymond.icloud.apis.admin.service.fallbackFactory.ITSysUserServiceFallbackFactory;
import org.raymond.icloud.apis.admin.vo.LoginRequestVO;
import org.raymond.icloud.apis.admin.vo.LoginResponseVO;
import org.raymond.icloud.apis.admin.vo.UserInfoVO;
import org.raymond.icloud.apis.admin.vo.entity.SysUserVO;
import org.raymond.icloud.common.core.bean.PageBean;
import org.raymond.icloud.common.core.config.FeignConfiguration;
import org.raymond.icloud.common.core.model.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author raymond
 * @version V1.0
 * @Description: 后期再考虑负载均衡
 */
@FeignClient(name="i-cloud-client", contextId="admin-user",
        url="${icloud.services.ip}:${icloud.services.port}", path="icloud",
        configuration=FeignConfiguration.class,
        fallbackFactory=ITSysUserServiceFallbackFactory.class
)
@RequestMapping("/admin/user")
public interface ITSysUserServiceApi {

    @PostMapping("/create")
    Result<SysUserVO> create(@RequestBody SysUserVO vo);

    @GetMapping("/getByUsername")
    Result<SysUserVO> getByUsername(@RequestParam(value="username") String username);

    @PostMapping("/update")
    Result<SysUserVO> update(@RequestBody SysUserVO vo);

    @PostMapping("/delete")
    Result<Boolean> delete(@RequestBody SysUserVO vo);

    @GetMapping("/list")
    Result<PageBean<SysUserVO>> list(PageBean pageBean);

    // antdpro
    @PostMapping("/login")
    Result<LoginResponseVO> login(@RequestBody @Valid LoginRequestVO loginVO);

    @GetMapping("/current")
    Result<UserInfoVO> current();

    @PostMapping("/logout")
    Result<Boolean> logout();
}
